﻿﻿ <!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>发布项目</title>
    <link href="css/public_zc_1.css" rel="stylesheet"/>
    <link type="text/css" rel="stylesheet" href="css/tcal.css">
    <style>
        .nav ul .nav_a4 a:link, .nav ul .nav_a4 a:visited {
            color: #fff;
        }

        .nav ul .nav_a4 a, .nav ul .nav_a4 a:hover {
            background: url(images/zc_top.png) no-repeat -60px -30px;
        }

        .apply_left {
            float: left;
            width: 720px;
            background: #fafafa;
            height: 780px;
            padding-top: 20px;
        }

        .apply_right {
            float: left;
            width: 280px;
            background: url(images/apply_10.png) repeat-y #fafafa;
            height: 800px;
        }

        .apply_tb {
            font-size: 14px;
        }

        .apply_tb tr th {
            width: 130px;
            text-align: right;
            font-weight: 400;
            padding: 10px 6px 10px 0;
        }

        .apply_tb tr td {
            padding: 10px 0;
        }

        .apply_time em {
            color: #ddd;
        }

        .apply_val {
            padding: 0 3px;
            border: 1px solid #ddd;
            margin: 0;
            height: 33px;
            line-height: 33px \9;
        }

        .apply_btn {
            background: #6DB823;
            color: #fff;
            border: 0;
            margin: 0;
            padding: 0;
            width: 140px;
            height: 46px;
            text-align: center;
            font-size: 18px;
            font-family: 'Microsoft Yahei', 微软雅黑;
            cursor: pointer;
        }

        .apply_btn:hover {
            background: #70c404
        }

        .apply_tb textarea {
            overflow-y: auto;
            font-size: 12px;
            padding: 3px;
            border: 1px solid #ddd;
        }

        .apply_right_list {
            padding: 15px 0 0 25px;
        }

        .apply_right_list li {
            height: 30px;
            line-height: 30px;
            font-size: 18px;
            font-family: 'Microsoft Yahei', 微软雅黑;
            color: #70c404;
            margin-bottom: 15px;
            background: url(images/apply_13.png) no-repeat;
            padding-left: 16px;
        }

        .header {
            position: relative;
        }

        .top_nav_ti {
            position: absolute;
            right: 0px;
            top: 60px;
            background: #fafce3;
            border: #f4dab2 solid 1px;
            color: #666;
            width: 147px;
            z-index: 10001;
            padding: 0 7px 10px 14px;
        }

        .top_nav_ti .arrow {
            position: absolute;
            width: 41px;
            height: 6px;
            background: url(images/arrow_tishi.png) center top no-repeat;
            left: 120px;
            top: -6px;
            overflow: hidden;
        }

        .top_nav_ti p {
            margin-top: 10px;
        }

        .top_nav_ti .view_btn {
            display: block;
            width: 50px;
            height: 22px;
            line-height: 22px;
            background: #ff7200;
            text-align: center;
            color: #fff;
            text-decoration: none;
            margin-top: 8px;
        }

        .top_nav_ti .view_btn:hover {
            background: #ff8421;
        }

        .header {
            position: relative;
        }

        .top_nav_ti {
            position: absolute;
            right: 0px;
            top: 60px;
            background: #fafce3;
            border: #f4dab2 solid 1px;
            color: #666;
            width: 147px;
            z-index: 10001;
            padding: 0 7px 10px 14px;
        }

        .top_nav_ti .arrow {
            position: absolute;
            width: 41px;
            height: 6px;
            background: url(images/arrow_tishi.png) center top no-repeat;
            left: 120px;
            top: -6px;
            overflow: hidden;
        }

        .top_nav_ti p {
            margin-top: 10px;
        }

        .top_nav_ti .view_btn {
            display: block;
            width: 50px;
            height: 22px;
            line-height: 22px;
            background: #ff7200;
            text-align: center;
            color: #fff;
            text-decoration: none;
            margin-top: 8px;
        }

        .top_nav_ti .view_btn:hover {
            background: #ff8421;
        }

        .displayNone {
            display: none;
        }

        .displayInlineBlock {
            display: inline-block;
        }

        .h_name:hover .popup {
            display: inline-block;
        }

        .h_message:hover .popup {
            display: inline-block;
        }

    </style>
    <script src="js/vue2.5.17.js"></script>
    <script src="js/kindeditor-all.js"></script>
    <script src="js/lang/zh-CN.js"></script>
    <script type="text/javascript" src="js/jquery1.7.js"></script>
    <script src="../admin/layui/layui.all.js"></script>
    <link rel="stylesheet" href="../admin/layui/css/layui.css">
</head>
<body>


<div class="header_bg">
    <div class="header wap">
        <div class="logo"><a href="/index.html" title="权名众筹系统">权名众筹系统</a></div>
        <div class="nav cfff">
            <ul>
                <li class="nav_a1"><a href="/index.html">首页</a></li>
                <li class="nav_a2"><a href="/home/list.html?projectName=&page=1&limit=10&type=0">全部项目</a></li>
                <li class="nav_a4"><a href="/home/apply.html">发布项目</a></li>                 <li class="nav_a5"><a href="/admin/index.html#/user/login">后台管理</a></li>


            </ul>
        </div>
        <div class="h_right" id="h_right_userInfo">
            <ul class="h_login h_user displayNone"
                v-bind:class="[userInfo.code===101 ? 'displayInlineBlock':'displayNone']" id="login_panel">
                <span>
                            <li class="hl_login"><a href="/home/login.html" class="h_login_ring">登录</a></li>
                            <li class="hl_reg"><a href="/home/sign.html" class="h_login_join">注册</a></li>
                            <li class="qq_login"><a href="#" title="QQ登陆">QQ登录</a></li>
                </span>
                <li class="help_login"><a href="#">帮助</a></li>
            </ul>
            <ul class="h_login  h_reg displayNone"
                v-bind:class="[userInfo.code===0 ? 'displayInlineBlock':'displayNone']" id="login_info">
                <div>
                    <li class="h_name"><a href="/home/user/user.html">{{userInfo.data!=null ?userInfo.data.username:''}}</a>
                        <div class="popup name_popup cfff displayNone">
                            <a href="/home/user/user.html">我的帐户</a>
                            <a href="/home/logout">安全退出</a>
                        </div>
                    </li>
<!--<li class="h_message"><a href="#" id="notify">提醒</a>-->                         <!--<div class="popup message_popup cfff displayNone">-->                             <!--<a href="#" id="unread">未读通知 </a>-->                             <!--<a href="#" id="unreview">待评价项目 </a>-->                             <!--<a href="#" id="uncash">未兑现项目 </a>-->                         <!--</div>-->                     <!--</li>-->

                    <li class="help_login"><a href="#">帮助</a></li>
                </div>
            </ul>
        </div>
        <div class="top_nav_ti" style="display: none;" id="tips_help">
            <span class="arrow"></span>
            <p>初来乍到？先看看帮助吧！</p>
            <a href="#" class="view_btn" id="close_help">知道啦</a>
        </div>
    </div>
</div>


<div class="content wap content_about">
    <div class="bread_crumbs"><a href="../index.html">首页</a>&nbsp;&gt;&nbsp;<a href="apply">发布项目</a></div>
    <div>
        <form class="layui-form" action="" lay-filter="apply_form">
            <div class="layui-form-item">
                <label class="layui-form-label">项目名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入项目名称"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">项目简介</label>
                <div class="layui-input-block">
                    <input type="text" name="description" lay-verify="required" autocomplete="off" placeholder="请输入项目简介"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">Banner</label>
                <div class="layui-input-inline">
                    <input name="banner" lay-verify="required" id="LAY_avatarSrc" placeholder="图片地址"  class="layui-input">
                </div>
                <div class="layui-input-inline layui-btn-container" style="width: auto;">
                    <button type="button" class="layui-btn layui-btn-primary" id="LAY_avatarUpload">
                        <i class="layui-icon">&#xe67c;</i>上传图片
                    </button>
                    <button class="layui-btn layui-btn-primary" id="show_banner">查看图片</button >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">目标金额</label>
                <div class="layui-input-block">
                    <input type="text" name="money" lay-verify="required|number" autocomplete="off" placeholder="请输入目标金额"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">单份金额</label>
                <div class="layui-input-block">
                    <input type="text" name="singleMoney" lay-verify="required|number" autocomplete="off" placeholder="请输入单份金额"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">份额数量</label>
                <div class="layui-input-block">
                    <input type="number" name="singleCount" lay-verify="required|number" autocomplete="off" placeholder="请输入份额数量"
                           class="layui-input">
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">开始日期</label>
                <div class="layui-input-inline">
                    <input type="text" name="startTime" id="date1" lay-verify="datetime" placeholder="yyyy-MM-dd hh:mm:ss"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">结束日期</label>
                <div class="layui-input-inline">
                    <input type="dat" name="endTime" id="date2" lay-verify="datetime" placeholder="yyyy-MM-dd hh:mm:ss"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">项目类型</label>
                <div class="layui-input-inline">
                    <select name="projectType.typeId" id="project-type">
                        <option value="">请选择类型</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">项目回报</label>
                <div class="layui-input-block">
                    <textarea id="editor_huibao_id" class="layui-textarea" name="commodityDescription">
                    </textarea>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">详细介绍</label>
                <div class="layui-input-block">
                    <textarea id="editor_id" class="layui-textarea" name="detail" placeholder="请输入项目详细介绍"
                              style="width:100%;height:800px; border: #28a745 1px solid">
                    </textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>


    </div>
</div>

<div class="go_top" id="top_arrow">
    <p class="dingbu" style=""><a href="#top">返回顶部</a></p>
</div>
<div class="footer">
    <div class="ft_link_bg">
        <div class="ft_link">

            <dl class="ft_coop">
                <dt>合作伙伴</dt>
                <dd>


                </dd>
            </dl>
            <dl class="ft_help">
                <dt>帮助拓展</dt>

            </dl>
        </div>
    </div>
</div>
<link href="css/public_1.css" rel="stylesheet" media="all"/>
<div class="ws_global_footer">
    <div class="ws_footer_info" style="min-width: 1000px">
        <div class="content">
            <p>
                <a href="#" target="_blank">桂ICP备123456789</a>　
                权名众筹　
                权名众筹　
                权名众筹　
                <a href="#"
                   target="_blank"
                   style="width:16px;height:16px;display:inline-block;background:url('images/wen_icon.png')">&nbsp;</a>
            </p>
            <p>
                Copyright (C) 2018 权名众筹 Rights Reserved　
                 　
                　
                <a href="#" target="_blank">百度</a>
            </p>
        </div>
    </div>
</div>


<style>
    .show_public_tips {
        position: fixed;
        _position: absolute;
        top: 30%;
        left: 50%;
        width: 360px;
        margin: 0 0 0 -200px;
        background: #000;
        font-size: 18px;
        font-family: 'Microsoft Yahei', 微软雅黑;
        text-align: center;
        line-height: 40px;
        padding: 20px;
        z-index: 21000;
        _top: expression(documentElement.scrollTop + 150);
        border: 1px solid #555;
        color: #fff;
    }

    .show_public_tips_text {
        color: #fff;
    }
</style>
<!--[if (gt IE 9)|!(IE)]><!-->
<style>
    div.show_public_tips {
        background: rgba(0, 0, 0, 0.7);
        border-radius: 8px;
    }
</style>


<script type="text/javascript" src="js/jquery1.7.js"></script>

<script>
    //获取头部
    $.ajax({
        url: "/home/getCurrentUser",
        async: true,
        success: function (data) {
            if (data.code==101){
                alert("请先登录");
                window.location.href="/home/login.html";
            }
            new Vue({
                el: '#h_right_userInfo',
                data: {userInfo: data}
            })
            console.log(data)
        }
    });

    KindEditor.ready(function (K) {
        window.editor = K.create('#editor_id',
            {
                uploadJson: '/api/edit_upload',
                fileManagerJson: '/api/edit_upload',
                allowFileManager: true,
                afterBlur: function () {
                    this.sync();
                }
            });
        window.editor = K.create('#editor_huibao_id',
            {
                uploadJson: '/api/edit_upload',
                fileManagerJson: '/api/edit_upload',
                allowFileManager: true,
                afterBlur: function () {
                    this.sync();
                }
            });
    });

</script>


<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            ,$ = layui.$
            ,upload = layui.upload
        ;
        $.ajax({
            url: "/home/getAllProjectType",
            async: true,
            success: function (data) {
                $.each(data,function (i,v) {
                    $("#project-type").append("<option value='"+v.typeId+"'>"+v.typeName+"</option>"); //为Select追加一个Option(下拉项)
                })
                form.render();
            }
        });



        //普通图片上传
        var uploadInst = upload.render({
            elem: '#LAY_avatarUpload'
            ,url: '/api/upload/'
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                //上传成功
                $("#LAY_avatarSrc").val(res.src);

            }
        });


        //查看Banner
        $(document).on('click','#show_banner',function(){
            // layer.msg('hello');
            var json={
                "title": "", //相册标题
                "id": 123, //相册id
                "start": 0, //初始显示的图片序号，默认0
                "data": [   //相册包含的图片，数组格式
                    {
                        "alt": "图片名",
                        "pid": 666, //图片id
                        "src": $("#LAY_avatarSrc").val(), //原图地址
                        "thumb": "" //缩略图地址
                    }
                ]
            }
            layer.photos({
                photos: json
                ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
            });
            return false;
        });


        form.render();
        //日期
        laydate.render({
            elem: '#date1'
            ,type: 'datetime'
        });

        laydate.render({
            elem: '#date2'
            ,type: 'datetime'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //监听提交
        form.on('submit(demo1)', function (data) {
            console.log(data.field);
            // layer.alert(JSON.stringify(data.field), {
            //     title: '最终的提交信息'
            // });
            $.ajax({
                url: "/home/addProject",
                data:data.field,
                type:'POST',
                success: function (d) {
                    console.log(d)
                    if (d.code==0){
                        alert("创建成功");
                        window.location.href="/home/project.html?id="+d.data.projectId;

                    } else if (d.code==101){
                        layer.alert("请先登录", {
                            title: '失败'
                        },function (a) {
                            window.location.href="/home/login.html";
                        });

                    }

                }
            });

            return false;
        });

        //表单初始赋值
                form.val('apply_form', {
                    "projectType.typeId": 1 // "name": "value"
                })


    });
</script>


</body>
</html>
